<?php
/**
 * Introduction: 微信端登录验证
 * @author: 杨陈鹏
 * @email: yangchenpeng@cdlinglu.com
 */

namespace Common\Controller\WeChat;


use Think\Controller;

class SignController extends Controller
{

    static public $uid;

    public function __construct()
    {

        parent::__construct();

        $this->checkLogin();

    }

    /**
     * Introduction: 检测微信端token
     * @author: 杨陈鹏
     * @email: yangchenpeng@cdlinglu.com
     */
    public function checkLogin()
    {

        $token = I('param.token');

        if(!$token && count($token) != 32)
            $this->ajaxReturn(['code' => 500, 'msg' => '请登录!']);

        $member_logic = D('Member','Logic');

        $uid = $member_logic::$model->where(['uuid' => $token])->getField('uid');

        if(!intval($uid))
            $this->ajaxReturn(['code' => 500, 'msg' => '用户不存在!']);

        self::$uid = $uid;

    }


}